package com.echovin.esb.gateway.mapper;

import com.echovin.esb.gateway.model.GatewayAccessLog;
import org.apache.ibatis.annotations.*;

@Mapper
public interface GatewayAccessLogMapper {
    @SelectKey(keyProperty = "record.id", resultType = String.class, before = true,
            statement = "select replace(uuid(), '-', '')")
    @Options(keyProperty = "record.id", useGeneratedKeys = true)
    @Insert("insert into GATEWAY_ACCESS_LOG(ID,ACTION_ID,PARAMS,HEADER,METHOD,IP,REGION,HTTP_STATUS,REQUEST_TIME,RESPONSE_TIME,USE_TIME,AUTHENTICATION,RESPONSE,ERROR,CALLER_ID,CALLER_NAME,SERVICE_ID,SERVICE_NAME,CREATER,CREATE_TIME) " +
            "values(#{record.id},#{record.actionId},#{record.params},#{record.header},#{record.method},#{record.ip},#{record.region},#{record.httpStatus},#{record.requestTime},#{record.responseTime},#{record.useTime},#{record.authentication},#{record.response},#{record.error},#{record.callerId},#{record.callerName},#{record.serviceId},#{record.serviceName},#{record.creater},#{record.createTime})")
    int insert(@Param("record") GatewayAccessLog record);

    @Update("update GATEWAY_ACCESS_LOG set IS_DELETE = 1, UPDATER = #{record.updater}, UPDATE_TIME = #{record.updateTime} where ID = #{record.id}")
    int delete(GatewayAccessLog record);
}
